importClass(android.app.WallpaperManager)


var wpm = WallpaperManager.getInstance(context);
//var Q = manager.getDrawable();

//manager.setResource(1);

importClass(android.graphics.BitmapFactory);
importClass(android.graphics.Bitmap);
importClass(android.graphics.Rect);
if (wpm != null) {
    var mBitmap = BitmapFactory.decodeFile("/storage/emulated/0/Pictures/壁纸/9.png"); //path为绝对路径
    //第一个参数是Bitmap对象，第二个参数是截取图片的大小矩形，第三个参数是是否备份
    wpm.setBitmap(mBitmap, new Rect(0, 0, 1440, 3120), false);
}
